package com.kly.sc.api.application.service.trade;

import com.fqgj.common.api.Response;
import com.kly.dto.MemberDto;
import com.kly.dto.ProductDto;
import com.kly.dto.ReduceBenefitsDto;
import com.kly.service.MemberBenefitsService;
import com.kly.service.MemberService;
import com.kly.service.UserVasPurchasesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.validation.Valid;

@Service
public class ApiMemberService {

    @Resource
    MemberService memberService;

    @Resource
    MemberBenefitsService memberBenefitsService;

    @Resource
    UserVasPurchasesService userVasPurchasesService;


    /**
     * 新增会员福利
     *
     * @param member  会员
     * @param product 产品
     * @return 新增结果
     */
    public Response saveMemberBenefits(MemberDto member, ProductDto product) {
        return memberBenefitsService.saveMemberBenefits(member, product);
    }

    /**
     *  获取会员服务使用次数
     * @param reduceBenefits    会员号、服务类型
     */
    public Response getMemberBenefits(ReduceBenefitsDto reduceBenefits) {
        return memberBenefitsService.getMemberBenefits(reduceBenefits.getMemberCode(), reduceBenefits.getBenefitCode());
    }

    /**
     * 获取增值服务使用次数
     * @param reduceBenefits    用户码、、服务类型
     * @return  使用次数
     */
    Response getUserPurchasesBenefits(ReduceBenefitsDto reduceBenefits) {
        return userVasPurchasesService.getUserPurchasesBenefits(
                reduceBenefits.getUserCode(), reduceBenefits.getBenefitCode());
    }

    /**
     * 扣减会员服务次数
     *
     * @param reduceBenefits 扣减服务类型
     * @return 扣减结果
     */
    Response reduceMemberBenefits(ReduceBenefitsDto reduceBenefits) {

        return memberBenefitsService.reduceMemberBenefits(reduceBenefits);
    }
}
